<script setup>
import { ref } from 'vue'
import CircleInfo from '@/components/CircleInfo.vue'
import { useUserStore } from '@/stores/user'
import axiosInstance from '@/utils/request'
import { TOKEN } from '@/utils/constant'
const store = useUserStore()
const friendCircles = ref([])
// 获取当前用户朋友圈
const getFriendCircles = () => {
  axiosInstance
    .get('/friend-circle/list', {
      headers: {
        TOKEN: store.token
      }
    })
    .then((response) => {
      console.log(response)
      friendCircles.value = response.data.data
      console.log(friendCircles.value)
    })
    .catch((error) => {
      console.log(error)
    })
}
getFriendCircles()
</script>
<template>
  <div class="moments">
    <NavBarHeader>
      <template #title>朋友圈</template>
    </NavBarHeader>
    <div class="contact-list">
      <ul>
        <li class="contact-item">
          <img :src="store.user.avatar" alt="头像" class="avatar" />
          <div class="contact-info">
            <p style="color: #000" class="nickname">
              {{ store.user.nickname }}
            </p>
          </div>
        </li>
      </ul>
    </div>
    <div v-for="friendCircle in friendCircles" :key="friendCircle.id">
      <CircleInfo
        :friendCircle="friendCircle"
        :isLike="friendCircle.chatFriendCircle.isLike"
        :likeNum = "friendCircle.chatFriendCircle.likeNum"
        @delete-success="getFriendCircles"
      />
    </div>
  </div>
</template>

<style scoped>
.moments {
  padding: 10px;
}
.contact-list {
  padding: 10px;
}

.contact-item {
  display: flex;
  align-items: center;
  padding: 10px;
  margin-bottom: 10px; /* 每个联系人之间的间距 */
  border-radius: 8px; /* 圆角 */
  background-color: #fff; /* 背景颜色 */
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1); /* 阴影效果 */
  transition: all 0.3s ease; /* 过渡效果 */
}
.contact-item:hover {
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2); /* 悬停时的阴影效果 */
}

.avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  margin-right: 10px;
}

.contact-info {
  flex-grow: 1; /* 使信息部分占据可用空间 */
}

.nickname {
  font-size: 16px;
  font-weight: bold;
  color: #000;
}
</style>
